<?php
namespace app\shop\model;
use app\BaseModel;
use think\facade\Db;



class Wholesale extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_shop_wholesale';
    
    protected $append = [

        'num_text',

    ];


    /**
     * @author chenniang
     * @DataTime: 2021-01-29 17:33
     * @功能说明:
     */
    public function getNumTextAttr($value,$data){

        if(isset($data['min'])&&isset($data['max'])){

            return $data['min'].'-'.$data['max'];

        }

    }


    /**
     * @author chenniang
     * @DataTime: 2021-01-19 10:44
     * @功能说明:查询
     */
    public function dataInfo($dis){

        $data = $this->where($dis)->find();


        return $data->toArray();

    }



    /**
     * @author chenniang
     * @DataTime: 2021-01-19 10:36
     * @功能说明:编辑
     */
   public function dataUpdate($dis,$data){

       $res = $this->where($dis)->update($data);
       
       return $res;

   }


    /**
     * @author chenniang
     * @DataTime: 2021-01-29 15:53
     * @功能说明:添加批发价规则
     */
   public function dataAdd($data){

       foreach ($data['range'] as $v ){

           $insert = [

               'uniacid' => $data['uniacid'],

               'goods_id'=> $data['goods_id'],

               'spe_id'  => $data['spe_id'],

               'min'     => $v['min'],

               'min'     => $v['min'],

               'min'     => $v['min'],

           ];

       }


   }













}